# Maintainer: Ray Donnelly <mingw.android@gmail.com>

_realname=rust

pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=r31923.27e8d5b
pkgrel=1
pkgdesc="A safe, concurrent, practical language from Mozilla (mingw-w64)"
arch=('any')
url="https://www.rust-lang.org/"
license=('custom:MIT' 'Apache')
#depends=('shared-mime-info')
makedepends=('git'
      "${MINGW_PACKAGE_PREFIX}-gcc"
      "${MINGW_PACKAGE_PREFIX}-llvm"
      'curl'
      "${MINGW_PACKAGE_PREFIX}-libffi"
      'python2'
      )
options=('!makeflags' 'staticlibs')
#install=rust.install
source=("${_realname}"::"git+https://github.com/mozilla/rust.git")
sha256sums=('SKIP')
pkgver() {
  cd "$srcdir"/$_realname
  printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
}
prepare() {
  cd ${srcdir}/${_realname}
}

build() {
  mkdir -p "${srcdir}"/build-${CARCH}
  #export CFG_LLVM_ROOT=${MINGW_PREFIX}
  cd "${srcdir}"/build-${CARCH}
    ../${_realname}/configure \
    --prefix=${MINGW_PREFIX} \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --target=${MINGW_CHOST}
    #--llvm-root=${MINGW_PREFIX}      use the system's llvm, doesn't work currently (31082014)
    #--enable-local-rust              use an installed rustc rather than downloading a snapshot
    #--local-rust-root=[/usr/local]   set prefix for local rust binary
    #--enable-clang                   prefer clang to gcc for building the runtime

    make VERBOSE=1
}

package() {
    cd "${srcdir}"/build-${CARCH}
    make DESTDIR=${pkgdir} install
}
